import http from '@/api/teacherapi'
const state={
    tchcourse:{},
    homeworkinfo:{},
    homeworkconcrete:{}
};
const actions={
    async gettchcourse({commit},name){
        let res=await http.gettchcourse(name);
        if(res.status==200){
            commit("GETTCHCOURSE",res.data)
        }
    },
    changetchcoursepage({commit},page){
        commit("CHANGETCHCOURSEPAGE",page);
    },
    async gettchcoursebyname({commit},data){
        let res=await http.searchtchcourse(data);
        if(res.status==200){
            commit("GETTCHCOURSEBYNAME",res.data);
        }
    },
    async gethomeworkinfo({commit},name){
        let res=await http.gethomeworkinfo(name);
        if(res.status==200){
            commit("GETHOMEWORKINFO",res.data);
        }
    },
    changecoursehwpage({commit},page){
        commit("CHANGECOURSEHWPAGE",page);
    },
    async getcoursehwbyname({commit},data){
        let res=await http.getcoursehwbyname(data);
        if(res.status==200){
            commit("GETCOURSEHWBYNAME",res.data);
        }
    },
    async gethwconcrete({commit},data){
        let res=await http.gethwconcrete(data);
        if(res.status==200){
            commit("GETHWCONCRETE",res.data);
        }
    },
    changehwinfopage({commit},page){
        commit("CHANGEHWINFOPAGE",page);
    },
    async searchhwbyname({commit},data){
        let res=await http.searchhwbyname(data);
        if(res.status==200){
            commit("SEARCHHWBYNAME",res.data);
        }
    }
};
const mutations={
    GETTCHCOURSE(state,data){
        state.tchcourse=data;
    },
    CHANGETCHCOURSEPAGE(state,page){
        state.tchcourse.currentpage=page;
    },
    GETTCHCOURSEBYNAME(state,data){
        state.tchcourse=data;
    },
    GETHOMEWORKINFO(state,data){
        state.homeworkinfo=data;
    },
    CHANGECOURSEHWPAGE(state,page){
        state.homeworkinfo.currentpage=page;
    },
    GETCOURSEHWBYNAME(state,data){
        state.homeworkinfo=data;
    },
    GETHWCONCRETE(state,data){
        state.homeworkconcrete=data;
    },
    CHANGEHWINFOPAGE(state,page){
        state.homeworkconcrete.currentpage=page;
    },
    SEARCHHWBYNAME(state,data){
        state.homeworkconcrete=data;
    }
    
};
const getters={};
export default{
    state,actions,mutations,getters
}